package oop.basicConcept;

/*
    定义一个交通工具(Vehicle)的类
    属性：速度(speed)，体积(size)等等
    方法：
        移动(move(int s))
        设置速度(setSpeed(int speed))
        加速speedUp()
        减速speedDown()等等.
    最后在测试类Vehicle中的main()中实例化一个交通工具对象
    并通过方法给它初始化speed,size的值，并且通过方法打印出来
    另外，调用加速，减速的方法对速度进行改变。调用 move方法输出移动距离
 */

public class Vehicle {

    int speed;
    double size;
    int distance;

    public void move(int time){
        this.distance = this.getSpeed() * time;
    }

    public int getDistance(){
        return this.distance;
    }

    /**
     * 设置速度
     * @param speed 需要设置的速度值
     */
    public void setSpeed(int speed){
        this.speed = speed;
    }

    /**
     * 获取当前对象的speed属性值
     * @return 速度
     */
    public int getSpeed(){
        return this.speed;
    }

    public void setSize(double size){
        this.size = size;
    }

    public double getSize(){
        return this.size;
    }

    public void speedUp(){
        this.speed = this.speed+1;
    }

    public void speedDown(){
        this.speed = this.speed-1;
    }

    public static void main(String[] args) {
        Vehicle v = new Vehicle();
        //初始化速度值
        v.setSpeed(100);
        //初始化体积
        v.setSize(10.15);

        System.out.println(v.getSpeed());
        System.out.println(v.getSize());

        v.speedUp();
        v.speedUp();
        v.speedUp();
        v.speedUp();
        v.speedUp();

        System.out.println(v.getSpeed());

        v.speedDown();
        v.speedDown();
        v.speedDown();

        System.out.println(v.getSpeed());

        v.move(10);
        System.out.println(v.getDistance());

    }
}
